<template>
  <div ref="containerRef" class="container"></div>
</template>
<script setup>
import { ref, onMounted, onBeforeUnmount } from "vue";
import { initEcharts, disposeEcharts } from "@/config/echartsUtil";
const containerRef = ref(null);
let myChart = null;
const init = () => {
  const option = {
    title: {
      text: "ECharts 入门示例123",
    },
    tooltip: {},
    xAxis: {
      data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
    },
    yAxis: {},
    series: [
      {
        name: "销量",
        type: "bar",
        data: [5, 20, 36, 10, 10, 20],
        color: ["#91ca8c"],
      },
    ],
  };
  myChart = initEcharts(containerRef.value, option);
};
onBeforeUnmount(() => {
  //   销毁实例;
  disposeEcharts(myChart);
});
onMounted(() => {
  init();
});
</script>
<style lang="less" scoped></style>
